package com.gp.controller;

import com.gp.entity.MaintainRecord;
import com.gp.service.MaintainRecordService;
import com.gp.util.CommonResult;
import com.gp.vo.MaintainRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @program:carrent-pro
 * @author: luzzh
 * @Time: 2022-03-10 10:46
 * @Version: 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("maintain/record")
@Api(tags = "维护记录")
public class MaintainRecordController {
    @Autowired
    private MaintainRecordService maintainRecordService;

    @ApiOperation(value = "查询维修信息+模糊查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", dataType = "int", value = "当前页", required = true),
            @ApiImplicitParam(name = "pageSize", dataType = "int", value = "当前页显示几条数据", required = true),
            @ApiImplicitParam(name = "MaintainRecordVo", dataType = "MaintainRecordVo", value = "模糊查询", required = false)
    })
    @PostMapping("/findByPage/{currentPage}/{pageSize}")
    public CommonResult findByPage(@PathVariable(value = "currentPage") Integer currentPage, @PathVariable(value = "pageSize") Integer pageSize,@RequestBody MaintainRecordVo maintainRecordVo) {
        System.out.println(maintainRecordVo.toString());
        return maintainRecordService.findByPage(currentPage, pageSize, maintainRecordVo);
    }


    @PutMapping("/updateRecord")
    public CommonResult updateRecord(@RequestBody MaintainRecord maintainRecord){
        return maintainRecordService.updateRecord(maintainRecord);
    }

    @DeleteMapping("/deleteById")
    public CommonResult deleteById(Integer id){
        return maintainRecordService.deleteById(id);
    }

}
